﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Login
{
    public partial class FormControlLoop : FormBase
    {
        public FormControlLoop(ToolStripMenuItem tsmi) : base(tsmi)
        {
            InitializeComponent();
        }

        private void btnLoop_Click(object sender, EventArgs e)
        {
            TreeNode tnRoot = new TreeNode(Name);
            tvControls.Nodes.Add(tnRoot);
            RecursiveControls(tnRoot, this);
            tvControls.ExpandAll();
        }

        //深度遍历
        void RecursiveControls(TreeNode tnParent, Control ctParent)
        {
            foreach (Control c in ctParent.Controls)
            {
                TreeNode tn = new TreeNode(c.Name);
                tnParent.Nodes.Add(tn);
                RecursiveControls(tn, c);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            FormMgr formMgr = new FormMgr();
            formMgr.Show();
            formMgr.Tag = this;
        }

        private void tvControls_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            tvControls.SelectedNode = e.Node;
        }

        private void tvControls_AfterSelect(object sender, TreeViewEventArgs e)
        {

        }
    }
}
